import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
const path = require('path')
// 字体库
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
const pathResolve = dir => resolve(__dirname, dir)

// https://vitejs.dev/config/
export default defineConfig({
	plugins: [
		vue(),
		// 字体库
		createSvgIconsPlugin({
			iconDirs: [resolve(process.cwd(), 'src/assets/svg')],
			symbolId: 'icon-[dir]-[name]',
		})
	],
	css: {
		preprocessorOptions: {
			scss: {
				silenceDeprecations: ['legacy-js-api'],
			},
		},
	},
	// 这个是配置scss
	pluginOptions: {
		'style-resources-loader': {
			preProcessor: 'scss',
			patterns: []
		}
	},
	server: {
		port: 8080, // 默认启动端口号
		open: true, // 自动打开默认游览器
		cors: true, //允许跨域
	},
	resolve: {
		alias: {
			'@': path.resolve(__dirname, 'src'), // 设置 `@` 指向 `src` 目录
		}
	},

	define: {
		// enable hydration mismatch details in production build
		__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'true'
	}
})
